/* 
 *	Copyright (C) 2009-2010 miaohua
 *	http://code.google.com/p/lrcshower/
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */
#pragma once

#include "TypeDef.h"

// Unicode to multibytes
bool WildStr2MultiBytes(const std::wstring & src, std::string & dest);
// Multibytes to unicode
bool MultiBytes2WildStr(const std::string & src, std::wstring & dest);
// Trim the left and right spaces in the string also including ending '\n' & '\r'
void TrimStr(tstring & Str);
// Change char in str to lower case
void ToLower(tstring & Str);
// string format wrappter, use variable parameters
tstring StrFormat(const TCHAR * Format,...);
// Encode the song name(encode the chinese character to http url format, like %XX)
std::string ChEncode(const std::string & Word);

// Helper inline functions for multi-bytes converted to wild string , and vice versa
inline std::wstring MB2WS(const std::string & Src)
{
     std::wstring Dest;
     MultiBytes2WildStr(Src, Dest);
     return Dest;
}

inline std::string WS2MB(const std::wstring & Src)
{
     std::string Dest;
     WildStr2MultiBytes(Src, Dest);
     return Dest;
}

// OutputDebugstring wrapper, use variable parameters
void _Dbg_Printf (const TCHAR * Format,...);

// Convert a string to a word(the string must only contain 1~9, a~f, A~F)
DWORD CvtHexToNum(const tstring & Hex);
// Convert a word to string
tstring CvtNumToHex(DWORD Num);
// Convert from int to string or wstring(wrapper for _itot_s)
tstring IntToStr(int i);
// Format string number(like 24, or 23,456,234) to Arabic numerals 
unsigned int FormatNum(const tstring & Num);

// Get the application's tmp directory
// (if the directory "tmp" in application's working directory does not exist, then the fuction will create it)
// Path[out]: variable to get the result
// TmpDirName[in]: the name of tmp directory name, the default one is "tmp" which is defined in Config.h
bool GetTmpDir(tstring & Path, const tstring & TmpDirName);
// Check wether the given full path does exist
bool IsFileExist(const tstring & FullPath);

// Generate download url
tstring UrlGenHelper(const tstring & Template, const tstring & Word, int Count);